<?php

namespace Admin\Controller;

use Think\Controller;

class ChatController extends Controller
{
    public function index()
    {
        $info = M('Chat')->field('userid,chatid,content,addtime,trade_id')->select();

        foreach ($info as $k => $v) {
            $username = M('User')->where(array(
                'id' => $v['userid']
            ))->getField('username');

            $info[$k]['username'] = $username;

            $chatname = M('User')->where(array(
                'id' => $v['userid']
            ))->getField('username');

            $info[$k]['chatname'] = $chatname;
        }

        $this->ajaxReturn($info);
    }
}